package com.jt.web.controller;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jt.pojo.ItemDesc;
import com.jt.util.ObjectMapperUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JSONPController {
    @RequestMapping("/web/testJSONP")
//    JSONPObject将object转换为json并发送出去
    public JSONPObject jsonp(String callback){
        ItemDesc itemDesc=new ItemDesc();
        itemDesc.setItemId(10L).setItemDesc("跨域");
       /* String json= ObjectMapperUtil.toJSON(itemDesc);
        return callback+"("+json+")";*/
       return new JSONPObject("turn", itemDesc);
    }
}
